<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/webjars/jquery/3.4.1/jquery.js"></script>
</head>
<body>
<button onclick="add()">新增</button>
<form action="/del" method="post" onsubmit="return del()">
    <input type="submit" value="删除">
    <table border="1">
        <tr align="center">
            <td>选择</td>
            <td>编号</td>
            <td>书名</td>
            <td>价格</td>
            <td>类目</td>
            <td>库存</td>
            <td>图片</td>
            <td>说明</td>
            <td>作者</td>
            <td>已售</td>
        </tr>
        <tr th:each="list:${page.records}">
            <td><input type="checkbox" name="id" class="id" th:value="${list.id}"></td>
            <td th:text="${list.id}"></td>
            <td th:text="${list.name}"></td>
            <td th:text="${list.price}"></td>
            <td th:text="${list.category}"></td>
            <td th:text="${list.pnum}"></td>
            <td th:text="${list.imgurl}"></td>
            <td th:text="${list.description}"></td>
            <td th:text="${list.author}"></td>
            <td th:text="${list.sales}"></td>
            <td>
                <button th:onclick="'javascript:upd('+${list.id}+')'">修改</button>
            </td>
        </tr>
    </table>
</form>
总的页数：<span th:text="${page.pages}"></span>&nbsp;&nbsp;总的记录数：<span th:text="${page.total}"></span>&nbsp;&nbsp;当前页的记录数：<span
        th:text="${page.size}"></span>&nbsp;&nbsp;当前页：<span th:text="${page.current}"></span>
&nbsp;&nbsp;&nbsp;
<a th:href="@{/queryAll(pageNum=${page.current - 1})}" th:if="${page.current > 1}">上一页</a>
<span th:each="p:${#numbers.sequence(1,page.pages)}">
        <a th:href="@{/queryAll(pageNum=${p})}" th:text="${p}"></a>
    </span>
<a th:href="@{/queryAll(pageNum=${page.current + 1})}" th:if="${page.current < page.pages}">下一页</a>
</body>

<script>
    function del() {
        if ($(".id:checked").length > 0) {
            if (confirm("确认删除吗")) {
                return true
            } else {
                alert("已取消删除")
                return false
            }
        } else {
            alert("请选择删除项！");
            return false
        }

    }

    function add() {
        window.location.href = "/sert";
    }

    function upd(id) {
        window.location.href = "upd?id="+id
    }
</script>
</html>